package chapter09plus

/**
 * Created with IntelliJ IDEA.
 * ClassName: Test02_Implicit
 * Package: chapter09plus
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 *          Date: 2023-07-01
 *          Time: 11:48
 */

//隐式转换
object Test02_Implicit {
  def main(args: Array[String]): Unit = {
    val new12 = new myRichInt(12)
    println(new12.myMax(15))

    //定义隐式转换函数
    implicit def convert(num :Int):myRichInt = new myRichInt(num)

    println(new12.myMax(15))

  }
}


class myRichInt(val self: Int) {
  def myMax(n: Int): Int = if (n < self) self else n

  def MyMax(n: Int): Int = if (n < self) n else self

}
